#include<cstdio>//uncle-lu
#include<cstring>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int n, ans;
int F[100010], line[100010];

int main()
{
	while(~scanf("%d", &line[++n]));
	
	for (int i = 1; i <= n; i++) 
		for (int j = 0; j <= i-1; j++) 
			if(line[i] <= line[j])
				F[i] = std::max(F[i], F[j] + 1);

	ans = 0;
	for (int i = 1; i <= n; i++) 
		ans = std::max(ans, F[i]);
	
	printf("%d\n", ans);

	memset(F, 0, sizeof(F));
	for (int i = 1; i <= n; i++) 
		for (int j = 0; j <= i-1; j++) 
			if(line[i] > line[j])
				F[i] = std::max(F[i], F[j] + 1);

	ans = 0;
	for (int i = 1; i <= n; i++) 
		ans = std::max(ans, F[i]);

	printf("%d", ans);

	return 0;
}
